// $ANTLR 3.1.2 D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g 2009-06-09 19:24:17

package org.protege.owl.examples.tab.grammar;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

import org.antlr.runtime.tree.*;

public class FOLStage2Parser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "DOT", "NOT", "FORALL", "SEPARATOR", "EXISTS", "RANGE_CLAUSE", "ID", "OR", "AND", "IS", "STAT", "QTF", "NEG", "EXPR", "VAR", "REL", "NEWLINE", "WS", "','", "':'", "';'"
    };
    public static final int STAT=14;
    public static final int T__24=24;
    public static final int T__23=23;
    public static final int T__22=22;
    public static final int QTF=15;
    public static final int FORALL=6;
    public static final int REL=19;
    public static final int SEPARATOR=7;
    public static final int NOT=5;
    public static final int ID=10;
    public static final int AND=12;
    public static final int EOF=-1;
    public static final int WS=21;
    public static final int EXPR=17;
    public static final int NEWLINE=20;
    public static final int RANGE_CLAUSE=9;
    public static final int IS=13;
    public static final int OR=11;
    public static final int NEG=16;
    public static final int VAR=18;
    public static final int EXISTS=8;
    public static final int DOT=4;

    // delegates
    // delegators


        public FOLStage2Parser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public FOLStage2Parser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return FOLStage2Parser.tokenNames; }
    public String getGrammarFileName() { return "D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g"; }


    public static class stat_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "stat"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:18:1: stat : qtflist expr DOT -> ^( STAT qtflist expr ) ;
    public final FOLStage2Parser.stat_return stat() throws RecognitionException {
        FOLStage2Parser.stat_return retval = new FOLStage2Parser.stat_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token DOT3=null;
        FOLStage2Parser.qtflist_return qtflist1 = null;

        FOLStage2Parser.expr_return expr2 = null;


        Object DOT3_tree=null;
        RewriteRuleTokenStream stream_DOT=new RewriteRuleTokenStream(adaptor,"token DOT");
        RewriteRuleSubtreeStream stream_qtflist=new RewriteRuleSubtreeStream(adaptor,"rule qtflist");
        RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:19:2: ( qtflist expr DOT -> ^( STAT qtflist expr ) )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:20:2: qtflist expr DOT
            {
            pushFollow(FOLLOW_qtflist_in_stat38);
            qtflist1=qtflist();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_qtflist.add(qtflist1.getTree());
            pushFollow(FOLLOW_expr_in_stat40);
            expr2=expr();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_expr.add(expr2.getTree());
            DOT3=(Token)match(input,DOT,FOLLOW_DOT_in_stat42); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_DOT.add(DOT3);



            // AST REWRITE
            // elements: qtflist, expr
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 20:19: -> ^( STAT qtflist expr )
            {
                // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:20:22: ^( STAT qtflist expr )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(STAT, "STAT"), root_1);

                adaptor.addChild(root_1, stream_qtflist.nextTree());
                adaptor.addChild(root_1, stream_expr.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "stat"

    public static class qtflist_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "qtflist"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:23:1: qtflist : ( qtf )* -> ^( QTF ( qtf )* ) ;
    public final FOLStage2Parser.qtflist_return qtflist() throws RecognitionException {
        FOLStage2Parser.qtflist_return retval = new FOLStage2Parser.qtflist_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        FOLStage2Parser.qtf_return qtf4 = null;


        RewriteRuleSubtreeStream stream_qtf=new RewriteRuleSubtreeStream(adaptor,"rule qtf");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:24:2: ( ( qtf )* -> ^( QTF ( qtf )* ) )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:25:2: ( qtf )*
            {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:25:2: ( qtf )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==NOT) ) {
                    int LA1_1 = input.LA(2);

                    if ( (LA1_1==FORALL||LA1_1==EXISTS) ) {
                        alt1=1;
                    }


                }
                else if ( (LA1_0==FORALL||LA1_0==EXISTS) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:25:2: qtf
            	    {
            	    pushFollow(FOLLOW_qtf_in_qtflist65);
            	    qtf4=qtf();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_qtf.add(qtf4.getTree());

            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);



            // AST REWRITE
            // elements: qtf
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 25:7: -> ^( QTF ( qtf )* )
            {
                // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:25:10: ^( QTF ( qtf )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(QTF, "QTF"), root_1);

                // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:25:16: ( qtf )*
                while ( stream_qtf.hasNext() ) {
                    adaptor.addChild(root_1, stream_qtf.nextTree());

                }
                stream_qtf.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "qtflist"

    public static class qtf_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "qtf"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:28:1: qtf : ( NOT qtfpart -> ^( NEG qtfpart ) | qtfpart -> qtfpart );
    public final FOLStage2Parser.qtf_return qtf() throws RecognitionException {
        FOLStage2Parser.qtf_return retval = new FOLStage2Parser.qtf_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NOT5=null;
        FOLStage2Parser.qtfpart_return qtfpart6 = null;

        FOLStage2Parser.qtfpart_return qtfpart7 = null;


        Object NOT5_tree=null;
        RewriteRuleTokenStream stream_NOT=new RewriteRuleTokenStream(adaptor,"token NOT");
        RewriteRuleSubtreeStream stream_qtfpart=new RewriteRuleSubtreeStream(adaptor,"rule qtfpart");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:29:2: ( NOT qtfpart -> ^( NEG qtfpart ) | qtfpart -> qtfpart )
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==NOT) ) {
                alt2=1;
            }
            else if ( (LA2_0==FORALL||LA2_0==EXISTS) ) {
                alt2=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;
            }
            switch (alt2) {
                case 1 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:30:2: NOT qtfpart
                    {
                    NOT5=(Token)match(input,NOT,FOLLOW_NOT_in_qtf87); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_NOT.add(NOT5);

                    pushFollow(FOLLOW_qtfpart_in_qtf89);
                    qtfpart6=qtfpart();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_qtfpart.add(qtfpart6.getTree());


                    // AST REWRITE
                    // elements: qtfpart
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 30:14: -> ^( NEG qtfpart )
                    {
                        // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:30:17: ^( NEG qtfpart )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(NEG, "NEG"), root_1);

                        adaptor.addChild(root_1, stream_qtfpart.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;}
                    }
                    break;
                case 2 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:32:2: qtfpart
                    {
                    pushFollow(FOLLOW_qtfpart_in_qtf103);
                    qtfpart7=qtfpart();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_qtfpart.add(qtfpart7.getTree());


                    // AST REWRITE
                    // elements: qtfpart
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 32:10: -> qtfpart
                    {
                        adaptor.addChild(root_0, stream_qtfpart.nextTree());

                    }

                    retval.tree = root_0;}
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "qtf"

    public static class qtfpart_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "qtfpart"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:35:1: qtfpart : ( forall | exists );
    public final FOLStage2Parser.qtfpart_return qtfpart() throws RecognitionException {
        FOLStage2Parser.qtfpart_return retval = new FOLStage2Parser.qtfpart_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        FOLStage2Parser.forall_return forall8 = null;

        FOLStage2Parser.exists_return exists9 = null;



        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:36:2: ( forall | exists )
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==FORALL) ) {
                alt3=1;
            }
            else if ( (LA3_0==EXISTS) ) {
                alt3=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 3, 0, input);

                throw nvae;
            }
            switch (alt3) {
                case 1 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:37:2: forall
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_forall_in_qtfpart119);
                    forall8=forall();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, forall8.getTree());

                    }
                    break;
                case 2 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:39:2: exists
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_exists_in_qtfpart125);
                    exists9=exists();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, exists9.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "qtfpart"

    public static class forall_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "forall"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:42:1: forall : FORALL rng SEPARATOR -> ^( FORALL rng ) ;
    public final FOLStage2Parser.forall_return forall() throws RecognitionException {
        FOLStage2Parser.forall_return retval = new FOLStage2Parser.forall_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token FORALL10=null;
        Token SEPARATOR12=null;
        FOLStage2Parser.rng_return rng11 = null;


        Object FORALL10_tree=null;
        Object SEPARATOR12_tree=null;
        RewriteRuleTokenStream stream_FORALL=new RewriteRuleTokenStream(adaptor,"token FORALL");
        RewriteRuleTokenStream stream_SEPARATOR=new RewriteRuleTokenStream(adaptor,"token SEPARATOR");
        RewriteRuleSubtreeStream stream_rng=new RewriteRuleSubtreeStream(adaptor,"rule rng");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:43:2: ( FORALL rng SEPARATOR -> ^( FORALL rng ) )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:44:2: FORALL rng SEPARATOR
            {
            FORALL10=(Token)match(input,FORALL,FOLLOW_FORALL_in_forall137); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_FORALL.add(FORALL10);

            pushFollow(FOLLOW_rng_in_forall139);
            rng11=rng();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_rng.add(rng11.getTree());
            SEPARATOR12=(Token)match(input,SEPARATOR,FOLLOW_SEPARATOR_in_forall141); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_SEPARATOR.add(SEPARATOR12);



            // AST REWRITE
            // elements: FORALL, rng
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 44:23: -> ^( FORALL rng )
            {
                // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:44:26: ^( FORALL rng )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(stream_FORALL.nextNode(), root_1);

                adaptor.addChild(root_1, stream_rng.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "forall"

    public static class exists_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "exists"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:47:1: exists : EXISTS rng SEPARATOR -> ^( EXISTS rng ) ;
    public final FOLStage2Parser.exists_return exists() throws RecognitionException {
        FOLStage2Parser.exists_return retval = new FOLStage2Parser.exists_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token EXISTS13=null;
        Token SEPARATOR15=null;
        FOLStage2Parser.rng_return rng14 = null;


        Object EXISTS13_tree=null;
        Object SEPARATOR15_tree=null;
        RewriteRuleTokenStream stream_SEPARATOR=new RewriteRuleTokenStream(adaptor,"token SEPARATOR");
        RewriteRuleTokenStream stream_EXISTS=new RewriteRuleTokenStream(adaptor,"token EXISTS");
        RewriteRuleSubtreeStream stream_rng=new RewriteRuleSubtreeStream(adaptor,"rule rng");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:48:2: ( EXISTS rng SEPARATOR -> ^( EXISTS rng ) )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:49:2: EXISTS rng SEPARATOR
            {
            EXISTS13=(Token)match(input,EXISTS,FOLLOW_EXISTS_in_exists161); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_EXISTS.add(EXISTS13);

            pushFollow(FOLLOW_rng_in_exists163);
            rng14=rng();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_rng.add(rng14.getTree());
            SEPARATOR15=(Token)match(input,SEPARATOR,FOLLOW_SEPARATOR_in_exists165); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_SEPARATOR.add(SEPARATOR15);



            // AST REWRITE
            // elements: rng, EXISTS
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 49:23: -> ^( EXISTS rng )
            {
                // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:49:26: ^( EXISTS rng )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(stream_EXISTS.nextNode(), root_1);

                adaptor.addChild(root_1, stream_rng.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "exists"

    public static class rng_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "rng"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:52:1: rng : varlist RANGE_CLAUSE expr -> varlist ^( EXPR expr ) ;
    public final FOLStage2Parser.rng_return rng() throws RecognitionException {
        FOLStage2Parser.rng_return retval = new FOLStage2Parser.rng_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token RANGE_CLAUSE17=null;
        FOLStage2Parser.varlist_return varlist16 = null;

        FOLStage2Parser.expr_return expr18 = null;


        Object RANGE_CLAUSE17_tree=null;
        RewriteRuleTokenStream stream_RANGE_CLAUSE=new RewriteRuleTokenStream(adaptor,"token RANGE_CLAUSE");
        RewriteRuleSubtreeStream stream_varlist=new RewriteRuleSubtreeStream(adaptor,"rule varlist");
        RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:53:2: ( varlist RANGE_CLAUSE expr -> varlist ^( EXPR expr ) )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:54:2: varlist RANGE_CLAUSE expr
            {
            pushFollow(FOLLOW_varlist_in_rng185);
            varlist16=varlist();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_varlist.add(varlist16.getTree());
            RANGE_CLAUSE17=(Token)match(input,RANGE_CLAUSE,FOLLOW_RANGE_CLAUSE_in_rng187); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_RANGE_CLAUSE.add(RANGE_CLAUSE17);

            pushFollow(FOLLOW_expr_in_rng189);
            expr18=expr();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_expr.add(expr18.getTree());


            // AST REWRITE
            // elements: expr, varlist
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 54:28: -> varlist ^( EXPR expr )
            {
                adaptor.addChild(root_0, stream_varlist.nextTree());
                // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:54:39: ^( EXPR expr )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(EXPR, "EXPR"), root_1);

                adaptor.addChild(root_1, stream_expr.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "rng"

    public static class varlist_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "varlist"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:57:1: varlist : ID ( ',' ID )* -> ^( VAR ( ID )+ ) ;
    public final FOLStage2Parser.varlist_return varlist() throws RecognitionException {
        FOLStage2Parser.varlist_return retval = new FOLStage2Parser.varlist_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token ID19=null;
        Token char_literal20=null;
        Token ID21=null;

        Object ID19_tree=null;
        Object char_literal20_tree=null;
        Object ID21_tree=null;
        RewriteRuleTokenStream stream_22=new RewriteRuleTokenStream(adaptor,"token 22");
        RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");

        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:58:2: ( ID ( ',' ID )* -> ^( VAR ( ID )+ ) )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:59:2: ID ( ',' ID )*
            {
            ID19=(Token)match(input,ID,FOLLOW_ID_in_varlist211); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_ID.add(ID19);

            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:59:5: ( ',' ID )*
            loop4:
            do {
                int alt4=2;
                int LA4_0 = input.LA(1);

                if ( (LA4_0==22) ) {
                    alt4=1;
                }


                switch (alt4) {
            	case 1 :
            	    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:59:6: ',' ID
            	    {
            	    char_literal20=(Token)match(input,22,FOLLOW_22_in_varlist214); if (state.failed) return retval; 
            	    if ( state.backtracking==0 ) stream_22.add(char_literal20);

            	    ID21=(Token)match(input,ID,FOLLOW_ID_in_varlist216); if (state.failed) return retval; 
            	    if ( state.backtracking==0 ) stream_ID.add(ID21);


            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);



            // AST REWRITE
            // elements: ID
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 59:15: -> ^( VAR ( ID )+ )
            {
                // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:59:18: ^( VAR ( ID )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(VAR, "VAR"), root_1);

                if ( !(stream_ID.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_ID.hasNext() ) {
                    adaptor.addChild(root_1, stream_ID.nextNode());

                }
                stream_ID.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "varlist"

    public static class expr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "expr"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:62:1: expr : orexpr ( OR orexpr )* ;
    public final FOLStage2Parser.expr_return expr() throws RecognitionException {
        FOLStage2Parser.expr_return retval = new FOLStage2Parser.expr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token OR23=null;
        FOLStage2Parser.orexpr_return orexpr22 = null;

        FOLStage2Parser.orexpr_return orexpr24 = null;


        Object OR23_tree=null;

        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:63:2: ( orexpr ( OR orexpr )* )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:64:2: orexpr ( OR orexpr )*
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_orexpr_in_expr239);
            orexpr22=orexpr();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) adaptor.addChild(root_0, orexpr22.getTree());
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:64:9: ( OR orexpr )*
            loop5:
            do {
                int alt5=2;
                int LA5_0 = input.LA(1);

                if ( (LA5_0==OR) ) {
                    alt5=1;
                }


                switch (alt5) {
            	case 1 :
            	    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:64:10: OR orexpr
            	    {
            	    OR23=(Token)match(input,OR,FOLLOW_OR_in_expr242); if (state.failed) return retval;
            	    if ( state.backtracking==0 ) {
            	    OR23_tree = (Object)adaptor.create(OR23);
            	    root_0 = (Object)adaptor.becomeRoot(OR23_tree, root_0);
            	    }
            	    pushFollow(FOLLOW_orexpr_in_expr245);
            	    orexpr24=orexpr();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) adaptor.addChild(root_0, orexpr24.getTree());

            	    }
            	    break;

            	default :
            	    break loop5;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "expr"

    public static class orexpr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "orexpr"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:67:1: orexpr : atom ( AND atom )* ;
    public final FOLStage2Parser.orexpr_return orexpr() throws RecognitionException {
        FOLStage2Parser.orexpr_return retval = new FOLStage2Parser.orexpr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token AND26=null;
        FOLStage2Parser.atom_return atom25 = null;

        FOLStage2Parser.atom_return atom27 = null;


        Object AND26_tree=null;

        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:68:2: ( atom ( AND atom )* )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:69:2: atom ( AND atom )*
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_atom_in_orexpr259);
            atom25=atom();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) adaptor.addChild(root_0, atom25.getTree());
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:69:7: ( AND atom )*
            loop6:
            do {
                int alt6=2;
                int LA6_0 = input.LA(1);

                if ( (LA6_0==AND) ) {
                    alt6=1;
                }


                switch (alt6) {
            	case 1 :
            	    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:69:8: AND atom
            	    {
            	    AND26=(Token)match(input,AND,FOLLOW_AND_in_orexpr262); if (state.failed) return retval;
            	    if ( state.backtracking==0 ) {
            	    AND26_tree = (Object)adaptor.create(AND26);
            	    root_0 = (Object)adaptor.becomeRoot(AND26_tree, root_0);
            	    }
            	    pushFollow(FOLLOW_atom_in_orexpr265);
            	    atom27=atom();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) adaptor.addChild(root_0, atom27.getTree());

            	    }
            	    break;

            	default :
            	    break loop6;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "orexpr"

    public static class atom_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "atom"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:72:1: atom : ( NOT quark -> ^( NOT quark ) | quark );
    public final FOLStage2Parser.atom_return atom() throws RecognitionException {
        FOLStage2Parser.atom_return retval = new FOLStage2Parser.atom_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NOT28=null;
        FOLStage2Parser.quark_return quark29 = null;

        FOLStage2Parser.quark_return quark30 = null;


        Object NOT28_tree=null;
        RewriteRuleTokenStream stream_NOT=new RewriteRuleTokenStream(adaptor,"token NOT");
        RewriteRuleSubtreeStream stream_quark=new RewriteRuleSubtreeStream(adaptor,"rule quark");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:73:2: ( NOT quark -> ^( NOT quark ) | quark )
            int alt7=2;
            int LA7_0 = input.LA(1);

            if ( (LA7_0==NOT) ) {
                alt7=1;
            }
            else if ( (LA7_0==ID||LA7_0==23) ) {
                alt7=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 7, 0, input);

                throw nvae;
            }
            switch (alt7) {
                case 1 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:74:2: NOT quark
                    {
                    NOT28=(Token)match(input,NOT,FOLLOW_NOT_in_atom279); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_NOT.add(NOT28);

                    pushFollow(FOLLOW_quark_in_atom281);
                    quark29=quark();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_quark.add(quark29.getTree());


                    // AST REWRITE
                    // elements: NOT, quark
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 74:12: -> ^( NOT quark )
                    {
                        // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:74:15: ^( NOT quark )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot(stream_NOT.nextNode(), root_1);

                        adaptor.addChild(root_1, stream_quark.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;}
                    }
                    break;
                case 2 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:76:2: quark
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_quark_in_atom295);
                    quark30=quark();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, quark30.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "atom"

    public static class quark_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "quark"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:79:1: quark : ( predcall | ':' expr ';' -> expr );
    public final FOLStage2Parser.quark_return quark() throws RecognitionException {
        FOLStage2Parser.quark_return retval = new FOLStage2Parser.quark_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token char_literal32=null;
        Token char_literal34=null;
        FOLStage2Parser.predcall_return predcall31 = null;

        FOLStage2Parser.expr_return expr33 = null;


        Object char_literal32_tree=null;
        Object char_literal34_tree=null;
        RewriteRuleTokenStream stream_23=new RewriteRuleTokenStream(adaptor,"token 23");
        RewriteRuleTokenStream stream_24=new RewriteRuleTokenStream(adaptor,"token 24");
        RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:80:2: ( predcall | ':' expr ';' -> expr )
            int alt8=2;
            int LA8_0 = input.LA(1);

            if ( (LA8_0==ID) ) {
                alt8=1;
            }
            else if ( (LA8_0==23) ) {
                alt8=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 8, 0, input);

                throw nvae;
            }
            switch (alt8) {
                case 1 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:81:2: predcall
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_predcall_in_quark307);
                    predcall31=predcall();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, predcall31.getTree());

                    }
                    break;
                case 2 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:83:2: ':' expr ';'
                    {
                    char_literal32=(Token)match(input,23,FOLLOW_23_in_quark313); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_23.add(char_literal32);

                    pushFollow(FOLLOW_expr_in_quark315);
                    expr33=expr();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_expr.add(expr33.getTree());
                    char_literal34=(Token)match(input,24,FOLLOW_24_in_quark317); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_24.add(char_literal34);



                    // AST REWRITE
                    // elements: expr
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 83:15: -> expr
                    {
                        adaptor.addChild(root_0, stream_expr.nextTree());

                    }

                    retval.tree = root_0;}
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "quark"

    public static class predcall_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "predcall"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:87:1: predcall : ( ( arg IS )=> arg IS ID -> ^( IS ID arg ) | arg1= arg ID arg2= arg -> ^( REL ID $arg1 $arg2) );
    public final FOLStage2Parser.predcall_return predcall() throws RecognitionException {
        FOLStage2Parser.predcall_return retval = new FOLStage2Parser.predcall_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token IS36=null;
        Token ID37=null;
        Token ID38=null;
        FOLStage2Parser.arg_return arg1 = null;

        FOLStage2Parser.arg_return arg2 = null;

        FOLStage2Parser.arg_return arg35 = null;


        Object IS36_tree=null;
        Object ID37_tree=null;
        Object ID38_tree=null;
        RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleTokenStream stream_IS=new RewriteRuleTokenStream(adaptor,"token IS");
        RewriteRuleSubtreeStream stream_arg=new RewriteRuleSubtreeStream(adaptor,"rule arg");
        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:88:2: ( ( arg IS )=> arg IS ID -> ^( IS ID arg ) | arg1= arg ID arg2= arg -> ^( REL ID $arg1 $arg2) )
            int alt9=2;
            int LA9_0 = input.LA(1);

            if ( (LA9_0==ID) ) {
                int LA9_1 = input.LA(2);

                if ( (LA9_1==IS) && (synpred1_FOLStage2())) {
                    alt9=1;
                }
                else if ( (LA9_1==ID) ) {
                    alt9=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return retval;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 9, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 9, 0, input);

                throw nvae;
            }
            switch (alt9) {
                case 1 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:89:2: ( arg IS )=> arg IS ID
                    {
                    pushFollow(FOLLOW_arg_in_predcall344);
                    arg35=arg();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_arg.add(arg35.getTree());
                    IS36=(Token)match(input,IS,FOLLOW_IS_in_predcall346); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_IS.add(IS36);

                    ID37=(Token)match(input,ID,FOLLOW_ID_in_predcall348); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_ID.add(ID37);



                    // AST REWRITE
                    // elements: IS, ID, arg
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 90:13: -> ^( IS ID arg )
                    {
                        // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:90:16: ^( IS ID arg )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot(stream_IS.nextNode(), root_1);

                        adaptor.addChild(root_1, stream_ID.nextNode());
                        adaptor.addChild(root_1, stream_arg.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;}
                    }
                    break;
                case 2 :
                    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:92:2: arg1= arg ID arg2= arg
                    {
                    pushFollow(FOLLOW_arg_in_predcall366);
                    arg1=arg();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_arg.add(arg1.getTree());
                    ID38=(Token)match(input,ID,FOLLOW_ID_in_predcall368); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_ID.add(ID38);

                    pushFollow(FOLLOW_arg_in_predcall372);
                    arg2=arg();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_arg.add(arg2.getTree());


                    // AST REWRITE
                    // elements: arg2, ID, arg1
                    // token labels: 
                    // rule labels: retval, arg2, arg1
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
                    RewriteRuleSubtreeStream stream_arg2=new RewriteRuleSubtreeStream(adaptor,"rule arg2",arg2!=null?arg2.tree:null);
                    RewriteRuleSubtreeStream stream_arg1=new RewriteRuleSubtreeStream(adaptor,"rule arg1",arg1!=null?arg1.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 92:23: -> ^( REL ID $arg1 $arg2)
                    {
                        // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:92:26: ^( REL ID $arg1 $arg2)
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(REL, "REL"), root_1);

                        adaptor.addChild(root_1, stream_ID.nextNode());
                        adaptor.addChild(root_1, stream_arg1.nextTree());
                        adaptor.addChild(root_1, stream_arg2.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;}
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "predcall"

    public static class arg_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "arg"
    // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:95:1: arg : ID ;
    public final FOLStage2Parser.arg_return arg() throws RecognitionException {
        FOLStage2Parser.arg_return retval = new FOLStage2Parser.arg_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token ID39=null;

        Object ID39_tree=null;

        try {
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:96:2: ( ID )
            // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:97:2: ID
            {
            root_0 = (Object)adaptor.nil();

            ID39=(Token)match(input,ID,FOLLOW_ID_in_arg398); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            ID39_tree = (Object)adaptor.create(ID39);
            adaptor.addChild(root_0, ID39_tree);
            }

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "arg"

    // $ANTLR start synpred1_FOLStage2
    public final void synpred1_FOLStage2_fragment() throws RecognitionException {   
        // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:89:2: ( arg IS )
        // D:\\Projekty\\Protege4Workspace\\org.protege.editor.owl.examples.tab\\src\\org\\protege\\owl\\examples\\tab\\grammar\\FOLStage2.g:89:3: arg IS
        {
        pushFollow(FOLLOW_arg_in_synpred1_FOLStage2335);
        arg();

        state._fsp--;
        if (state.failed) return ;
        match(input,IS,FOLLOW_IS_in_synpred1_FOLStage2337); if (state.failed) return ;

        }
    }
    // $ANTLR end synpred1_FOLStage2

    // Delegated rules

    public final boolean synpred1_FOLStage2() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred1_FOLStage2_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }


 

    public static final BitSet FOLLOW_qtflist_in_stat38 = new BitSet(new long[]{0x0000000000800420L});
    public static final BitSet FOLLOW_expr_in_stat40 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_DOT_in_stat42 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_qtf_in_qtflist65 = new BitSet(new long[]{0x0000000000000162L});
    public static final BitSet FOLLOW_NOT_in_qtf87 = new BitSet(new long[]{0x0000000000000160L});
    public static final BitSet FOLLOW_qtfpart_in_qtf89 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_qtfpart_in_qtf103 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_forall_in_qtfpart119 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_exists_in_qtfpart125 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FORALL_in_forall137 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_rng_in_forall139 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_SEPARATOR_in_forall141 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_EXISTS_in_exists161 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_rng_in_exists163 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_SEPARATOR_in_exists165 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_varlist_in_rng185 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_RANGE_CLAUSE_in_rng187 = new BitSet(new long[]{0x0000000000800420L});
    public static final BitSet FOLLOW_expr_in_rng189 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_varlist211 = new BitSet(new long[]{0x0000000000400002L});
    public static final BitSet FOLLOW_22_in_varlist214 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_ID_in_varlist216 = new BitSet(new long[]{0x0000000000400002L});
    public static final BitSet FOLLOW_orexpr_in_expr239 = new BitSet(new long[]{0x0000000000000802L});
    public static final BitSet FOLLOW_OR_in_expr242 = new BitSet(new long[]{0x0000000000800420L});
    public static final BitSet FOLLOW_orexpr_in_expr245 = new BitSet(new long[]{0x0000000000000802L});
    public static final BitSet FOLLOW_atom_in_orexpr259 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_AND_in_orexpr262 = new BitSet(new long[]{0x0000000000800420L});
    public static final BitSet FOLLOW_atom_in_orexpr265 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_NOT_in_atom279 = new BitSet(new long[]{0x0000000000800420L});
    public static final BitSet FOLLOW_quark_in_atom281 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_quark_in_atom295 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_predcall_in_quark307 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_23_in_quark313 = new BitSet(new long[]{0x0000000000800420L});
    public static final BitSet FOLLOW_expr_in_quark315 = new BitSet(new long[]{0x0000000001000000L});
    public static final BitSet FOLLOW_24_in_quark317 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_arg_in_predcall344 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_IS_in_predcall346 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_ID_in_predcall348 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_arg_in_predcall366 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_ID_in_predcall368 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_arg_in_predcall372 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_arg398 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_arg_in_synpred1_FOLStage2335 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_IS_in_synpred1_FOLStage2337 = new BitSet(new long[]{0x0000000000000002L});

}